package main

import(
	"LianFaPhone/lfp-common"
	. "LianFaPhone/lfp-autoorder-liantong/config"
	"fmt"
	"encoding/json"
	"net/url"
)

type(
	RePicSubmit struct{

	}

	ResPicSubmit struct{
		Total   int   `json:"total"`
		Success  bool   `json:"success"`
		Message string `json:"message"`
	}
)

func (this * RePicSubmit) Send(oId string) error {

	heads := map[string]string{
		"Referer": GPreConfig.NowShopUrl.Url,
		"Content-Length": "6782",
	}
	formBody := make(url.Values)
	formBody.Add("previewImg_front", "")
	formBody.Add("previewImg_back",  "")
	formBody.Add("previewImg_person",  "")


	data,err := common.HttpFormSend(GPreConfig.NowShopUrl.Host+"/viceCard/submitPicNow.do?action=M&orderId="+oId, formBody, "POST", heads)
	if err != nil {
		return err
	}
	res := new(ResPicSubmit)

	err = json.Unmarshal(data, res)
	if err != nil {
		return err
	}
	if !res.Success {
		return fmt.Errorf("%v-%v", res.Success, res.Message)
	}
	return nil
}
